home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Report Writers / Crystal Repot 9.0 Full CD version / Setup.exe / Windows / System32 / HTMLRE90.DLL / HTML / 11815 < prev    next >
Encoding:
Text File  |  2002-07-05  |  5.1 KB  |  200 lines

  1. <script>
  2. // LOCALIZATION STRING
  3. var L_INVALID_SIZE = "The size is invalid.\nMillimeters must be between 0 and 3276.7, inclusive.  Inches must be between 0 and 129, inclusive.";
  4. </script>
  5.  
  6. <script>
  7.  
  8. var MMPERINCH = 25.4;
  9. var MAXMM = 3276.7;
  10. var MINMM = 0;
  11. var lastInchmm;
  12.  
  13. function InitCustomSize()
  14. {
  15.     var preferedUnit = "%1";
  16.     var width = %2;
  17.     var height = %3;
  18.  
  19.     if ( preferedUnit == "inch" )
  20.     {
  21.         document.layoutform.inchmm[0].checked = true;
  22.         lastInchmm = 0;
  23.         document.layoutform.visiblewidth.value = Math.round(width / MMPERINCH * 1000) / 1000;
  24.         document.layoutform.visibleheight.value = Math.round(height / MMPERINCH * 1000) / 1000;
  25.     }
  26.     else
  27.     {
  28.         document.layoutform.inchmm[1].checked = true;
  29.         lastInchmm = 1;
  30.         document.layoutform.visiblewidth.value = width;
  31.         document.layoutform.visibleheight.value = height;
  32.     }
  33.  
  34.     document.layoutform.customwidth.value = width;
  35.     document.layoutform.customheight.value = height;
  36. }
  37.  
  38. function ChangeInchmm()
  39. {
  40.     var oldWidth = Number( document.layoutform.customwidth.value );
  41.     var oldHeight = Number( document.layoutform.customheight.value );
  42.  
  43.     if ( isNaN( oldWidth ) || ( ( oldWidth < MINMM ) || ( oldWidth > MAXMM ) ) )
  44.     {
  45.         alert( L_INVALID_SIZE );
  46.  
  47.         document.layoutform.visiblewidth.focus();
  48.         document.layoutform.visiblewidth.select();
  49.  
  50.         document.layoutform.inchmm[lastInchmm].checked = true;
  51.         return false;
  52.     }
  53.  
  54.     if ( isNaN( oldHeight) || ( ( oldHeight < MINMM ) || ( oldHeight > MAXMM ) ) )
  55.     {
  56.         alert( L_INVALID_SIZE );
  57.  
  58.         document.layoutform.visibleheight.focus();
  59.         document.layoutform.visibleheight.select();
  60.  
  61.         document.layoutform.inchmm[lastInchmm].checked = true;
  62.         return false;
  63.     }
  64.  
  65.     if ( lastInchmm == 0 )
  66.         lastInchmm = 1;
  67.     else
  68.         lastInchmm = 0;
  69.  
  70.     if ( document.layoutform.inchmm[0].checked )
  71.     {
  72.         document.layoutform.visiblewidth.value = String( Math.round(oldWidth / MMPERINCH * 1000) / 1000 );
  73.         document.layoutform.visibleheight.value = String( Math.round(oldHeight / MMPERINCH * 1000) / 1000 );
  74.     }
  75.     else
  76.     {
  77.         document.layoutform.visiblewidth.value = String( Math.round(oldWidth * 10) / 10 );
  78.         document.layoutform.visibleheight.value = String( Math.round(oldHeight * 10) / 10 );
  79.     }
  80. }
  81.  
  82. function CheckCustomSize()
  83. {
  84.     UpdateWidth();
  85.     UpdateHeight();
  86.  
  87.     var isInch = document.layoutform.inchmm[0].checked;
  88.     var width = Number( document.layoutform.customwidth.value );
  89.     var height = Number( document.layoutform.customheight.value );
  90.  
  91.     // validate
  92.     if ( isNaN( width ) || ( ( width < MINMM ) || ( width > MAXMM ) ) )
  93.     {
  94.         alert( L_INVALID_SIZE );
  95.  
  96.         document.layoutform.visiblewidth.focus();
  97.         document.layoutform.visiblewidth.select();
  98.  
  99.         return false;
  100.     }
  101.  
  102.     if  ( isNaN( height ) || ( ( height < MINMM ) || ( height > MAXMM ) ) )
  103.     {
  104.         alert( L_INVALID_SIZE );
  105.  
  106.         document.layoutform.visibleheight.focus();
  107.         document.layoutform.visibleheight.select();
  108.  
  109.         return false;
  110.     }
  111.  
  112.     // ready to submit in mm
  113.     return true;
  114. }
  115.  
  116. function UpdateWidth()
  117. {
  118.     var value = Number(document.layoutform.visiblewidth.value);
  119.  
  120.     if ( isNaN( value ) )
  121.         document.layoutform.customwidth.value = document.layoutform.visiblewidth.value;
  122.     else
  123.     {
  124.         if ( document.layoutform.inchmm[0].checked )
  125.         {
  126.             document.layoutform.customwidth.value = value * MMPERINCH;
  127.             document.layoutform.visiblewidth.value = Math.round( document.layoutform.customwidth.value / MMPERINCH * 1000 ) / 1000;
  128.         }
  129.         else
  130.         {
  131.             document.layoutform.customwidth.value = value;
  132.         }
  133.     }
  134. }
  135.  
  136. function UpdateHeight()
  137. {
  138.     var value = Number(document.layoutform.visibleheight.value);
  139.  
  140.     if ( isNaN( value ) )
  141.         document.layoutform.customheight.value = document.layoutform.visibleheight.value;
  142.     else
  143.     {
  144.         if ( document.layoutform.inchmm[0].checked )
  145.         {
  146.             document.layoutform.customheight.value = value * MMPERINCH;
  147.             document.layoutform.visibleheight.value = Math.round( document.layoutform.customheight.value / MMPERINCH * 1000 ) / 1000;
  148.  
  149.         }
  150.         else
  151.         {
  152.             document.layoutform.customheight.value = value;
  153.         }
  154.     }
  155. }
  156.  
  157. </script>
  158.         <tr>
  159.             <td class='list'> </td>
  160.             <td class='list'>
  161.                 <table border=0 cellpadding=2 cellspacing=0>
  162.                 <tr>
  163.                     <td class="list" valign=middle>
  164.                         Measuring units:
  165.                     </td>
  166.                     <td class='list'>
  167.                         <table border=0 cellpadding=2 cellspacing=0>
  168.                         <tr>
  169.                             <td class="list" width=50% nowrap>
  170.                                 <input type="radio" name="inchmm" value="inch" onclick="ChangeInchmm();"> inches
  171.                             </td>
  172.                             <td class="list" nowrap>
  173.                                 <input type="radio" name="inchmm" value="mm" onclick="ChangeInchmm();"> millimeters
  174.                             </td>
  175.                         </tr>
  176.                         </table>
  177.                     </td>
  178.                 </tr>
  179.                 <tr>
  180.                     <td class='list'>
  181.                         Page width:
  182.                     </td>
  183.                     <td class='list'>
  184.                         <input type="text" name="visiblewidth" value="" size=6 onchange="UpdateWidth();">
  185.                         <input type="hidden" name="customwidth" value="">
  186.                     </td>
  187.                 </tr>
  188.                 <tr>
  189.                     <td class='list'>
  190.                         Page height:
  191.                     </td>
  192.                     <td class='list'>
  193.                         <input type="text" name="visibleheight" value="" size=6 onchange="UpdateHeight();">
  194.                         <input type="hidden" name="customheight" value="">
  195.                     </td>
  196.                 </tr>
  197.                 </table>
  198.             </td>
  199.         </tr>
  200.